﻿requirejs.config({
    baseUrl: ".",
    paths: {
    	zepto:"javascripts/zepto.min",
    	dingtalk:"javascripts/dingtalk",
        vue: "components/vue/vue.min",
        axios: "components/axios/axios.min",
        common: "resources/js/common"
    }
});

require(["zepto","dingtalk","vue", "axios", "common"], function (zepto,dingtalk,Vue, axios, common) {
    var vm = new Vue({
        el: "#view",
        data: {
            project: [],
            projectId: "",
            content: "",
            queryType: "incident",
            incidentStatus: "",
            result: []
        },
        mounted: function () {
            var self = this;
            self.query(20);
            //alert(common.getUsername())
            axios.get("/common/getUserInfo?userInfo=" + common.getUsername())
                .then(function (response) {

                    axios.get("/common/project?userId=" + response.data.id)
                        .then(function (projectResponse) {
                            self.project = projectResponse.data;
                        });
                });
        },
        methods: {
            query: function (top) {
                var self = this;

                axios.get(this.queryType + "/query?projectId=" + this.projectId + "&content=" + this.content + "&status=" + this.incidentStatus + "&top=" + top)
                    .then(function (response) {
                        self.result = response.data;
                    })
            },
            gotoIncidentDetail: function (id, status) {
                if (status == "待分派") {
                    window.location.href = "requesPoolAssignment.html?readonly=1&id=" + id;
                } else {
                    window.location.href = "incidentDetail.html?readonly=1&id=" + id;
                }
            }
        }
    });

});